﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 观察者模式
{
    /// <summary>
    /// 抽象观察者
    /// </summary>
    abstract class Observer
    {
        protected string name;

        protected ISubject subject;

        public Observer(string name, ISubject sub)
        {
            this.name = name;
            this.subject = sub;
        }

        public abstract void Update();
    }

    class StrockObserver : Observer
    {
        public StrockObserver(string name,ISubject subject) : base(name, subject) { }

        public override void Update()
        {
            Console.WriteLine("{0} {1} 关闭股票行情，继续工作！", this.subject.SubjectState, this.name);
        }
    }
}
